package cac.fenjian.resource.PointPackageSort.rest;

import cac.fenjian.resource.PointPackageSort.service.PackageSortTaskQueryService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

/**
 * 工作包分拣任务查询
 * 1.根据条件查询工作包
 * 2.根据工作包id查询AO列表
 * 3.根据AOid查询物料清单
 * 4.根据AOid查询配套清单
 */
@RestController
@RequestMapping("PackageSortTaskQueryRest")
public class PackageSortTaskQueryRest {

    @Autowired
    private PackageSortTaskQueryService packageSortTaskQueryService;

    //1.根据条件查询工作包
    @PostMapping("searchPackage")
    public PageInfo searchPackage(@RequestBody HashMap map){
        HashMap page = (HashMap) map.get("page");
        HashMap queryParam = (HashMap) map.get("queryParam");
        int currentPage = Integer.parseInt(page.get("currentPage").toString());
        int pageSize = Integer.parseInt(page.get("pageSize").toString());
        PageHelper.startPage(currentPage,pageSize);
        List<HashMap> list = packageSortTaskQueryService.queryPackage(queryParam);
        return new PageInfo(list);
    }

    //2.根据工作包id查询AO列表
    @PostMapping("searchAO")
    public List<HashMap> searchAO(@RequestBody HashMap map){
//        HashMap page = (HashMap) map.get("page");
//        HashMap queryParam = (HashMap) map.get("queryParam");
//        int currentPage = Integer.parseInt(page.get("currentPage").toString());
//        int pageSize = Integer.parseInt(page.get("pageSize").toString());
//        PageHelper.startPage(currentPage,pageSize);
//        List<HashMap> list = packageSortTaskQueryService.queryAO(queryParam);
//        return new PageInfo(list);
        return packageSortTaskQueryService.queryAO(map);
    }

    //3.根据AOid查询物料清单
    @PostMapping("searchMaterial")
    public List<HashMap> searchMaterial(@RequestBody HashMap map){
        return packageSortTaskQueryService.queryMaterial(map);
    }

    //4.根据AOid查询配套清单
    @PostMapping("searchSupportingFacilities")
    public List<HashMap> searchSupportingFacilities(@RequestBody HashMap map){
        return packageSortTaskQueryService.querySupportingFacilities(map);
    }



}
